package study.distributed.shardingjdbc.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import study.distributed.shardingjdbc.dao.normal.UserMapper;
import study.distributed.shardingjdbc.dao.sharding.ShardingUserMapper;
import study.distributed.shardingjdbc.model.normal.UserModel;

@Service
public class UserService {

    @Autowired
    UserMapper userMapper;
    @Autowired
    ShardingUserMapper shardingUserMapper;

    public UserModel getUserById() {
        return userMapper.selectByPrimaryKey(1);
    }

    public void insert() {
        UserModel userModel = new UserModel();
        userModel.setId(3);
        userModel.setName("third");
        shardingUserMapper.insert(userModel);
    }
}
